package utils;

/**
 *
 * @author fuujin
 */
public class ChatChannel extends Chat
{
    public ChatChannel( String name, ServerConnection server )
    {
        super( name, server );
    }

    public final void part()
    {
        write( "PART " + getName() + "\n" );
    }

    @Override
    protected final void handleCommand( final String command )
    {
        if( command.toLowerCase().startsWith( "/nick" ) )
        {
            String newNick = command.substring( 5 );
            nick( newNick );
        }
        else if( command.toLowerCase().startsWith( "/me " ) )
        {
            String message = command.substring( 4 );
            display_.printEmote( getCurrentNick(), message );
            emote( message );
        }
        else if( command.toLowerCase().startsWith( "/topic " ) )
        {
            String message = command.substring( 7 );
            topic( message );
        }
        else if( command.toLowerCase().startsWith( "/part" ) )
        {
            part();
        }
        else if( command.toLowerCase().startsWith( "/join " ) )
        {
            String channel = command.substring( 6 );
            join( channel );
        }
        else
        {
            display_.printWarningText( "Error: Not a real command or it is not supported yet.");
            display_.printNewLine();
        }
    }
}
